package naga.x.proxy;

import java.util.concurrent.TimeUnit;

import com.xcity.WindowsShutdown;
import com.xcity.config.ConfigLoader;
import com.xcity.game.common.MessageConst;
import com.xcity.pomelo.push.msg.TipPush;

import naga.x.App;
import naga.x.net.filter.ConnectionsFilter;

public class ProxyServer {
	
	static class MainLoop implements Runnable {
		@Override
		public void run() {
			App.getApp().getUpdater().update();
		}
	}

	public static void main(String[] args) throws Exception {
		ConfigLoader.init("config.json", Config.class);
		ConnectionsFilter.sessionCloseMessage = new TipPush(MessageConst.SERVER_CONNECTIONS_EXCEED);
		App.getApp().getConfig().getDictionary().setClassesOfRequest(null);
		App.getApp().getServiceManager().create(GameServerConnector.class);
		App.getApp().getServiceManager().create(ProxyPomeloClientSessionService.class);
		App.getApp().getSchedule().scheduleAtFixedRate(new MainLoop(), 0, 80, TimeUnit.MILLISECONDS);
		WindowsShutdown.listen();
	}

}
